<!DOCTYPE html>
<html>
	<head>
		<title>修改密码</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<!-- 所有的 css & js 资源 -->
		<link rel="stylesheet" href="https://unpkg.com/element-ui@2.13.0/lib/theme-chalk/index.css">
		<link rel="stylesheet" href="../../static/sa.css"> 
		<script src="https://unpkg.com/vue@2.6.10/dist/vue.min.js"></script>
		<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
		<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
		<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
		<script src="../../static/sa.js"></script>
		<style>
			.c-item .c-label{width: 10em;}
			.c-item .el-input__inner{width: 300px;}
        </style>
	</head>
	<body>
		<!-- 防止margin向下击穿 -->
		<div style="margin-top: -1em;"><br></div>
		<div class="vue-box" style="display: none;" :style="'display: block;'">

			<!-- 参数栏 -->
			<div style="padding: 1.5em;">
				<div class="c-title">修改密码</div>
				<el-form ref="form" id="form">
					<br>
					<div class="c-item">
						<label class="c-label">旧密码：</label>
						<el-input size="mini" v-model="m.old_pwd" type="password"></el-input>
					</div>		
					<br>
					<div class="c-item">
						<label class="c-label">再次输入旧密码：</label>
						<el-input size="mini" v-model="m.old_pwd2" type="password"></el-input>
					</div>		
					<br>
					<div class="c-item">
						<label class="c-label">新密码：</label>
						<el-input size="mini" v-model="m.new_pwd" type="password"></el-input>
					</div>
					<br>
					<div class="c-item">
						<label class="c-label">再次输入新密码：</label>
						<el-input size="mini" v-model="m.new_pwd2" type="password"></el-input>
					</div>
					<br>
					<div class="c-item">
						<label class="c-label"></label>
						<el-button type="primary" icon="el-icon-plus" size="mini" @click="ok">确定</el-button>
					</div>
				</el-form>
			</div>

		</div>
		<script>
			var app = new Vue({
				el: '.vue-box',
				data: {
					sa: sa,
					m: {
						old_pwd: '',
						old_pwd2: '',
						new_pwd: '',
						new_pwd2: ''
					},
				},
				methods: {
					// 提交 
					ok: function() {
						// 表单验证
						if(sa.isNull(this.m.old_pwd) || sa.isNull(this.m.new_pwd) || sa.isNull(this.m.new_pwd2) ) {
							return sa.msg('请填写');
						}
						if(this.m.old_pwd != this.m.old_pwd2 ) {
							return sa.msg('旧密码两次输入不一致');
						}
						if(this.m.new_pwd != this.m.new_pwd2 ) {
							return sa.msg('新密码两次输入不一致');
						}
						if(this.m.new_pwd.length < 4) {
							return sa.msg('新密码请不要低于六位数');
						}
						sa.ajax('/AdminPassword/update', this.m, function(res) {
							if(parent != window) {
								sa.closeCurrIframe();
								parent.sa.ok2('修改成功');
							}
						})
						//sa.$fast.fastUpdate2('/SysUser/updatePassword', this.m);
					},
				},
				mounted: function() {
					
				}
			})
		</script>
	</body>
</html>
